/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.techshop.controller.themes;

import com.techshop.model.Theme;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author Hai-PC
 */
@ManagedBean(name="themeSwitcherBean")
@RequestScoped
public class ThemeSwitcherBean
{      
    private List<Theme> advancedThemes;     
    private String theme;
    
    @ManagedProperty(value="#{guestPreferences}")
    private GuestPreferences guestPreferences;

    /**
     * @param guestPreferences the guestPreferences to set
     */
    public void setGuestPreferences(GuestPreferences guestPreferences)
    {
        this.guestPreferences = guestPreferences;
    }

    /**
     * @return the theme
     */
    public String getTheme()
    {
        return theme;
    }

    /**
     * @param theme the theme to set
     */
    public void setTheme(String theme)
    {
        this.theme = theme;
    }
    
    @PostConstruct
    public void init()
    {
        theme = guestPreferences.getTheme();
        
        advancedThemes = new ArrayList<>();
        getAdvancedThemes().add(new Theme("afterdark", "afterdark.png"));
        getAdvancedThemes().add(new Theme("afternoon", "afternoon.png"));
        getAdvancedThemes().add(new Theme("afterwork", "afterwork.png"));
        getAdvancedThemes().add(new Theme("aristo", "aristo.png"));
        getAdvancedThemes().add(new Theme("black-tie", "black-tie.png"));
        getAdvancedThemes().add(new Theme("blitzer", "blitzer.png"));
        getAdvancedThemes().add(new Theme("bluesky", "bluesky.png"));
        getAdvancedThemes().add(new Theme("bootstrap", "bootstrap.png"));
        getAdvancedThemes().add(new Theme("casablanca", "casablanca.png"));
        getAdvancedThemes().add(new Theme("cruze", "cruze.png"));
        getAdvancedThemes().add(new Theme("cupertino", "cupertino.png"));
        getAdvancedThemes().add(new Theme("dark-hive", "dark-hive.png"));
        getAdvancedThemes().add(new Theme("dot-luv", "dot-luv.png"));
        getAdvancedThemes().add(new Theme("eggplant", "eggplant.png"));
        getAdvancedThemes().add(new Theme("excite-bike", "excite-bike.png"));
        getAdvancedThemes().add(new Theme("flick", "flick.png"));
        getAdvancedThemes().add(new Theme("glass-x", "glass-x.png"));
        getAdvancedThemes().add(new Theme("home", "home.png"));
        getAdvancedThemes().add(new Theme("hot-sneaks", "hot-sneaks.png"));
        getAdvancedThemes().add(new Theme("humanity", "humanity.png"));
        getAdvancedThemes().add(new Theme("le-frog", "le-frog.png"));
        getAdvancedThemes().add(new Theme("midnight", "midnight.png"));
        getAdvancedThemes().add(new Theme("mint-choc", "mint-choc.png"));
        getAdvancedThemes().add(new Theme("overcast", "overcast.png"));
        getAdvancedThemes().add(new Theme("pepper-grinder", "pepper-grinder.png"));
        getAdvancedThemes().add(new Theme("redmond", "redmond.png"));
        getAdvancedThemes().add(new Theme("rocket", "rocket.png"));
        getAdvancedThemes().add(new Theme("sam", "sam.png"));
        getAdvancedThemes().add(new Theme("smoothness", "smoothness.png"));
        getAdvancedThemes().add(new Theme("south-street", "south-street.png"));
        getAdvancedThemes().add(new Theme("start", "start.png"));
        getAdvancedThemes().add(new Theme("sunny", "sunny.png"));
        getAdvancedThemes().add(new Theme("swanky-purse", "swanky-purse.png"));
        getAdvancedThemes().add(new Theme("trontastic", "trontastic.png"));
        getAdvancedThemes().add(new Theme("ui-darkness", "ui-darkness.png"));
        getAdvancedThemes().add(new Theme("ui-lightness", "ui-lightness.png"));
        getAdvancedThemes().add(new Theme("vader", "vader.png"));
    }
    
    public void saveTheme()
    {
        guestPreferences.setTheme(theme);
    }

    /**
     * @return the advancedThemes
     */
    public List<Theme> getAdvancedThemes()
    {
        return advancedThemes;
    }
}